package com.epam.task.xml.parsers;

import com.epam.task.xml.classes.Medicine;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import java.io.File;
import java.io.IOException;

@SuppressWarnings("deprecation")
public class SAXPars extends DefaultHandler {

    static Medicine ph = new Medicine();
    String thisElement = "";
    private String uid;

    public SAXPars(String xmlFile) throws ParserConfigurationException, SAXException {
        try {
            javax.xml.parsers.SAXParserFactory spf = SAXParserFactory.newInstance();
            spf.setValidating(false);
            javax.xml.parsers.SAXParser sp = spf.newSAXParser();
            SAXAnalyzer sax = new SAXAnalyzer();
            sp.parse(new File(xmlFile), sax);
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}